package com.health.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Publish/Subscribe模式-消费者
 */
@Component
public class Listener3 {

    @RabbitListener(bindings =@QueueBinding(
            value = @Queue("fanout.queue1"),
            exchange = @Exchange(value = "fanout.exchange",type = ExchangeTypes.FANOUT)))
    public void listen1(String msg){
        System.out.println("Publish/Subscribe模式》》 1号接收到消息："+msg);
    }

    @RabbitListener(bindings =@QueueBinding(
            value = @Queue("fanout.queue2"),
            exchange = @Exchange(value = "fanout.exchange",type = ExchangeTypes.FANOUT)))
    public void listen2(String msg){
        System.out.println("Publish/Subscribe模式》》 2号接收到消息："+msg);
    }


}
